Enabling
Windows XP Visual Styles
A programming
tutorial by Lim, Chooi Guan
Preface
I have
created this tutorial after reading an on-line reference on Microsoft’s MSDN
library on creating applications which recognise Visual XP styles. More information can be found at http://msdn.microsoft.com but the following
information should be more than enough to get you a headstart.
Introduction
Using
Windows XP you can now define the appearance of Window applications.
There are
a few visual styles included with Windows XP.
Using a few lines of code you can incorporate the Windows XP visual
style into your application.
The
non-client area is specified by the currently installed visual style, i.e.
window frame and non-client scrollbars.
To enable a visual style in an application’s client area you must use
the windows common controls library version 6.0 i.e. ComCtl32.dll. Version 6.0 is non-distributable and only
available in an operating system that contains it. By default applications use
version 5.0.
By adding
an application manifest which
indicates that version 6.0 common controls should be used when available, your
application will be able to take advantage of visual styles.
Enabling Visual Styles using an
external manifest file
The
easiest method would be to simply define a file with the following format. Make
changes to the file to the name field as well as description field.
<?xml
version="1.0" encoding="UTF-8"
standalone="yes"?>
<assembly
xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApp"
type="win32"
/>
<description>Your application description
here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
Save the
file in notepad as “YourApp.exe.manifest”. For example if your application is
called “qfr.exe”, save the above file as “qfr.exe.manifest”. Put the manifest file in the SAME directory
as the executable.
The
disadvantage of this method is that you’ll have to package the manifest file
externally. If it can’t be found, the
application will not be able to take advantage of the visual styles.
Enabling Visual Styles using an embedded
manifest file
This
method will guarantee the application takes advantage of visual styles, without
an external manifest file. The manifest
file is included as application source code.
You will
need the Windows XP Beta 2 SDK or later.
Steps
to follow
·
#include
“commctrl.h”
·
#define
SIDEBYSIDE_COMMONCONTROLS 1
·
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="CompanyName.ProductName.YourApp"
type="win32"
/>
<description>Your
application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
·
CREATEPROCESS_MANIFEST_RESOURCE_ID
RT_MANIFEST "YourApp.manifest"
That’s is!
Now compile and build your program’s executable. Switch between visual styles under Windows
XP, your application should take the look of the current visual style. If Windows XP is not available, then your
application should use version 5.0 of the common controls library. So either way, it’s a major boon for the
developer as the application will be able to recognise Visual XP styles when it
is released.
You can
check out my application “Quick File Rename” among others, which recognises visual
styles at http://minimice.cjb.net